use serde_derive::{Serialize, Deserialize};
use serde::{ser};
use std::default::Default;

#[derive(Serialize, Deserialize)]
pub struct JsonOK {
    pub code: u32,
}

#[derive(Serialize, Deserialize)]
pub struct JsonError<'a> {
    pub code: u32,
    pub message: &'a str,
}

#[derive(Serialize)]
pub struct JsonResult<T: ser::Serialize> {
    pub code: u32,
    pub result: T,
}

#[derive(Serialize)]
pub struct JsonAuth {
    pub authorization: String,
}

#[derive(Serialize, Default, Debug, Deserialize)]
pub struct JsonPager<T: ser::Serialize> {
    pub total: usize,
    pub pages: usize,
    pub time: f64, // 用于客户端时间修正
    pub rows: Option<Vec<T>>,
}